#import "UIScreen_SH.h"

@implementation UIScreen (SH)

+ (CGFloat)screenWidth
{
    static CGFloat         swidth = 0;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
      CGSize size = [UIScreen mainScreen].bounds.size;
      swidth      = MIN(size.width, size.height);
    });
    return swidth;
}

+ (CGFloat)screenHeight
{
    static CGFloat         sheight = 0;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
      CGSize size = [UIScreen mainScreen].bounds.size;
      sheight     = MAX(size.width, size.height);
    });
    return sheight;
}

+ (CGFloat)screenPixel
{
    static CGFloat         sp = 1;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
      CGFloat scale = [UIScreen mainScreen].scale;
      if (scale < 1) {
          scale = 1;
      }
      sp = 1.0 / scale;
    });
    return sp;
}

+ (NSString*)screenSizeString
{
    CGSize s = self.mainScreen.currentMode.size;
    return [NSString stringWithFormat:@"%.fx%.f", s.width, s.height];
}

+ (CGSize)screenSize
{
    return self.mainScreen.currentMode.size;
}

@end
